package com.crm.service.crm.businessOpportunities.controller;


import com.crm.model.common.dtos.ResponseResult;
import com.crm.model.crm.businessOpportunities.dto.FishForDto;
import com.crm.model.crm.businessOpportunities.dto.ReasonDto;
import com.crm.model.crm.businessOpportunities.dto.RecordsAllDto;
import com.crm.service.crm.businessOpportunities.service.CustomInfoService;
import com.crm.service.crm.businessOpportunities.service.RecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/business_opportunity")
public class BusinessController {

    @Autowired
    private RecordsService recordsService;

    @Autowired
    private CustomInfoService customInfoService;

    @PostMapping("/savelist")
    public ResponseResult saveAll(@RequestBody RecordsAllDto recordsAllDto){
        ResponseResult all = recordsService.saveAll(recordsAllDto);
        return all;
    }

    @GetMapping("/getById/{id}")
    public ResponseResult getById(@PathVariable Integer id){
        ResponseResult byId = recordsService.getById(id);
        return byId;
    }

    @PostMapping("/reason")
    public ResponseResult reason(@RequestBody ReasonDto reasonDto){
        ResponseResult responseResult = recordsService.saveReason(reasonDto);
        return responseResult;
    }

    @PostMapping("/allocation")
    public ResponseResult allocation(@RequestBody FishForDto fishForDto){
        ResponseResult responseResult = customInfoService.addByRevertId(fishForDto);
        return responseResult;
    }

}
